﻿using CERT.AcceptanceTests.InterfaceTests.DefaultValues;
using CERT.PageLibrary.Base;
using OpenQA.Selenium.Remote;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TechTalk.SpecFlow;

namespace CERT.AcceptanceTests
{

    public class FeatureBase : TestFixtureBase
    {
        #region Properties for Readability
        /// <summary>
        /// Shortcut property to Settings.CurrentSettings.Defaults for readability
        /// </summary>
        protected DefaultValues Default { get { return Settings.CurrentSettings.Defaults; } }

        /// <summary>
        /// Sets the Current page to the specified value - provided to help readability
        /// </summary>
        protected PageBase NextPage { set { CurrentPage = value; } }

        #endregion


        protected PageBase CurrentPage
        {

            get { return (PageBase)ScenarioContext.Current["CurrentPage"]; }

            set { ScenarioContext.Current["CurrentPage"] = value; }

        }



        [BeforeScenario]
        public void BeforeScenario()
        {
            if (!ScenarioContext.Current.ContainsKey("CurrentDriver"))
            {
                Test_Setup();
                ScenarioContext.Current.Add("CurrentDriver", CurrentDriver);
            }

            else
            {
                CurrentDriver = (RemoteWebDriver)ScenarioContext.Current["CurrentDriver"];
            }

        }


        [AfterScenario]
        public void AfterScenario()
        {
            if (ScenarioContext.Current.ContainsKey("CurrentDriver"))
            {
                Test_Teardown();
                ScenarioContext.Current.Remove("CurrentDriver");
            }
            string s = "";
        }

    }




}
